package DemoXunit;

/**
 * @ClassName Products
 * @Deacription TODO
 * @Author wenhowe
 * @Date 2020/4/29 19:47
 * @Version 1.0
 **/
public enum Products {
    SCARF(1, "围巾", 200, 0),
    HAT(2, "帽子", 120, 10),
    GLOVES(3, "手套", 80, 1);

    private int prodID; //商品ID
    private String prodName; //商品名称
    private int price; //商品价格
    private int count; //商品库存

    private Products(int prodID, String prodName, int price, int count) {
        this.prodID = prodID;
        this.prodName = prodName;
        this.price = price;
        this.count = count;
    }

    /**
     * 通过商品ID获取商品信息
     *
     * @param prodID
     * @return
     */
    public static Products getProd(int prodID) {
        for (Products product : Products.values()) {
            if (product.getProdID() == prodID) {
                return product;
            }
        }
        return null;
    }

    /**
     * getters and setters
     */
    public int getProdID() {
        return prodID;
    }

    public void setProdID(int prodID) {
        this.prodID = prodID;
    }

    public String getProdName() {
        return prodName;
    }

    public void setProdName(String prodName) {
        this.prodName = prodName;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
